package com.zx.zxapibackend.service.impl.inner;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zx.zxapibackend.model.domain.Auth;
import com.zx.zxapibackend.service.AuthService;
import com.zx.zxapicommon.service.InnerAuthService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;

import javax.annotation.Resource;

/**
 * @author 张旭
 * @version 1.0
 */
@DubboService
public class InnerAuthServiceImpl implements InnerAuthService {

    @Resource
    private AuthService authService;

    @Override
    public com.zx.zxapicommon.model.entity.Auth getAuth(String appId, String userId) {

        QueryWrapper<Auth> authQueryWrapper = new QueryWrapper<>();
        authQueryWrapper.eq("appid", appId);
        authQueryWrapper.eq("userid", userId);
        Auth one = authService.getOne(authQueryWrapper);
        if (one == null) {
            return null;
        }
        com.zx.zxapicommon.model.entity.Auth auth = new com.zx.zxapicommon.model.entity.Auth();
        BeanUtils.copyProperties(one, auth);
        return auth;
    }
}
